/*
 * @Author: ducafecat
 * @Description: 列表页
 * @Date: 2018-04-13 16:13:27
 * @Last Modified by: hans.taozhiwei
 * @Last Modified time: 2018-04-13 16:15:33
 */

import { list } from '@api/hmmm/subjects'

const app = {
  state: {
    name: '',
    list: []
  },
  mutations: {
    SET_NAME: (state, name) => {
      state.name = name
    },
    getlist (state, list) {
      state.list = list
    }
  },
  actions: {
    setName ({ commit }, userInfo) {
      const username = userInfo.username.trim()
      return new Promise((resolve, reject) => {
        commit('SET_NAME', username)
        resolve()
      })
    },
    async setlist (context) {
      const res = await list()
      console.log(res)
      context.commit('getlist')
    }
  }
}

export default app
